package graphic.primitives.car;

import graphic.primitives.general.GraphicObject;
import graphic.primitives.general.IGraphicObject;
import java.awt.Color;
/**
 * 
 * @author vit.terl
 *
 */
public class BackLight extends GraphicObject implements IGraphicObject{

	private boolean sviti;
	private int sirka;
	private int vyska;
	
	public BackLight(int x, int y, int sirka, int vyska) {
	super(x, y);
	this.sirka = sirka;
	this.vyska = vyska;
	}
		
	
	@Override
	public void redraw() {
		for(int i = 0; i <= vyska; i++) {
			mainWindow.line(x, y+i, x+sirka, y+i);
		}
		
		if(jeRozviceno()){
			
			for(int i = 0; i <= vyska; i++) {
				mainWindow.setColor(Color.red);
				mainWindow.line(x, y+i, x+sirka, y+i);
				mainWindow.setColor(Color.black);
			}
		}
	}
	
	public boolean jeRozviceno(){
		if(sviti==true) return true;
		else return false;
	}
	public void prepniSvetlo() {
		if(jeRozviceno()) zhasni();
		else rozsvit();
	}
	public void rozsvit() {
		sviti = true;
	}
	public void zhasni() {
		sviti = false;
	}
}
